<template>
  <div class="carbutton-wrapper">
    <i @click="reduce()" v-show="food.count>0" class="icon-jianhao1 iconfont icon"></i>
    <span v-show="food.count>0">{{food.count}}</span>
    <i class="icon-iconfontxinzeng iconfont" @click="add($event)"></i>
  </div>
</template>

<script>
  import Vue from 'vue'
  export default {
    components: {},
    props: {
      food: {
        type: Object
      }
    },
    mounted(){

//      console.log(this.food)
    },
    methods: {
      add(event){
        if (!this.food.count) {
          Vue.set(this.food, 'count', 1)
        } else {
          this.food.count++;
        }
        this.$emit('ball-event', event.target)
      },
      reduce(){
        this.food.count--;
      }
    }
  }
</script>
<style lang="less" scoped>
  @import "../../static/less/var.less";

  .carbutton-wrapper {
    font-size: @base*30rem;
    color: @mc;
    span {
      display: inline-block;
      width: @base*40rem;
      text-align: center;
      color: @mc;
      line-height: @base*30rem;
    }
  }
</style>
